package com.meida.app.provider.listener;

import com.meida.app.provider.handler.UserInfoHandler;
import com.meida.common.constants.QueueConstants;
import com.meida.common.mybatis.query.CriteriaSave;
import com.meida.common.base.utils.FlymeUtils;
import com.meida.module.user.client.entity.AppUser;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zyf
 */
@Component
public class RabbitMqListener {
    @Autowired(required = false)
    private UserInfoHandler userInfoHandler;


    /**
     * 用户注册扩展
     *
     * @param cs
     */
    @RabbitListener(queues = QueueConstants.QUEUE_USER_REG)
    public void userReg(CriteriaSave cs) {
        if (FlymeUtils.isNotEmpty(userInfoHandler)) {
            userInfoHandler.userReg(cs);
        }

    }

    /**
     * 绑定手机号扩展
     *
     * @param object
     * @return
     */
    @RabbitListener(queues = QueueConstants.QUEUE_BIND_MOBILE)
    public AppUser bindMobile(AppUser object) {
        if (FlymeUtils.isNotEmpty(userInfoHandler)) {
            userInfoHandler.bindMobile(object);
        }
        return object;
    }
}
